package businessdelegate;

/**
 * @Author: linKe
 * @Date: 2022/1/14 21:52
 * @FileName: BusinessDelegate
 * @version: 1.0
 * @Description: 业务委托类
 */
public class BusinessDelegate {
    /**
     * 业务查询服务
     */
    private BusinessLookupService lookupService;
    /**
     * 服务类别
     */
    private ServiceType serviceType;
    /**
     * 商业服务
     */
    private BusinessService businessService;

    public BusinessDelegate(BusinessLookupService lookupService) {
        this.lookupService = lookupService;
    }

    /**
     * 业务服务实现类切换方法  切换具体实现类对象
     * @param serviceType 服务类别
     */
    public void setServiceType(ServiceType serviceType) {
        this.serviceType = serviceType;
    }

    public void doTask() {
        // 获得对应类型实现的商业服务对象
        businessService = lookupService.getService(serviceType);
        // 调用过程方法
        businessService.process();
    }


}
